/// 1.引入json_annotation
import 'package:json_annotation/json_annotation.dart';

/// 2.指定此类的代码生成文件(格式：part '类名.g.dart';)
part 'login.g.dart';

/// 3.添加序列化标注
@JsonSerializable()
class LoginItem {
  @JsonKey(name: "nickName")
  final String nickName;
  @JsonKey(name: "phone")
  final String phone;
  @JsonKey(name: "email")
  final String email;

  LoginItem(this.nickName, this.phone, this.email);

  /// 4.添加反序列化方法
  /// (格式：factory 类名.fromJson(Map<String, dynamic> json) => _$类名FromJson(json);)
  factory LoginItem.fromJson(Map<String, dynamic> json) =>
      _$LoginItemFromJson(json);

  /// 5.添加序列化方法
  /// (格式：Map<String, dynamic> toJson() => _$类名ToJson(this);)
  Map<String, dynamic> toJson() => _$LoginItemToJson(this);
}
